import ajax, { ListResult } from '../ajax';

export function getList(data: any) {
  return ajax.post<ListResult>(`/ControlPanels/Dictionaries/Query`, data);
}

export function updateEntity(data: any) {
  if (!data.application) {
    data.applicationId = 10;
  }

  if (data.dictionaryId) {
    return ajax.put<any>('/ControlPanels/Dictionaries', data);
  } else {
    return ajax.post<any>('/ControlPanels/Dictionaries', data);
  }
}

export function deleteEntity(id: number) {
  let deleteCommand = { id: id };
  return ajax.put<any>(
    '/ControlPanels/Dictionaries/Actions/Delete',
    deleteCommand
  );
}
